<!DOCTYPE html>
<html lang="en">

<head>

  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    
  </style>
 

</head>

<body>
  
    <a href="http://www.baidu.com">百度</a>


  <script>
    let ahref = document.querySelector("a")
    ahref.addEventListener('click',function(e){
      
      //阻止事件的默认行为
      e.preventDefault();


      console.log("超链接被点击了..")

    })

  </script>


</body>

</html>